"use strict"

export const CONTENT_CHANGE = 'CONTENT_CHANGE'
export const CSS_CHANGE = 'CSS_CHANGE'
export const STYLE_CHANGE = 'STYLE_CHANGE'
export const FETCHING = 'FETCHING'
export const FETCHED = 'FETCHED'
export const FETCH_ERROR = 'FETCH_ERROR'
export const SWITCH_TO = 'SWITCH_TO'
export const RE_ORDER = 'RE_ORDER'
export const SELELCT_ELM = 'SELELCT_ELM'
export const MARK_EDITABLE = 'MARK_EDITABLE'
export const UNMARK_EDITABLE = 'UNMARK_EDITABLE'
export const DELETE_ELM = "DELETE_ELM"

export const UNDO = "UNDO"
export const REDO = "REDO"

export const FOCUS_ELM = "FOCUS_ELM"
export const DRAGING = "DRAGING"
export const DRAGED = "DRAGED"
export const EDITING = "EDITING"
export const EDITED = "EDITED"

export const RESIZING = "RESIZING"
export const RESIZED = "RESIZED"

export const FILE_QUEUED = 'FILE_QUEUED'
export const FILE_PROGRESS = 'FILE_PROGRESS'
export const FILE_STATUS_CHANGE = 'FILE_STATUS_CHANGE'
export const SELECT_PHOTO = 'SELECT_PHOTO'

export const SELECTED_PHOTO = 'SELECTED_PHOTO'
export const DELETED_PHOTO = 'DELETED_PHOTO'
export const SWITCH_PAGE = 'SWITCH_PAGE'

export const CROP_CHANGE = 'CROP_CHANGE'
export const CROPED = 'CROPED'
export const CROP_READY = 'CROP_READY'

export const SEARCHING = 'SEARCHING'
export const SEARCHED = 'SEARCHED'
export const SEARCH_FAILED = 'SEARCH_FAILED'
export const PLAY_MUSIC = 'PLAY_MUSIC'
export const PUASE_MUSIC = 'PUASE_MUSIC'
export const LOADED_MUSIC_SRC = 'LOADED_MUSIC_SRC'
export const SWITCH_SEARCH_PAGE = 'SWITCH_SEARCH_PAGE'
export const UPLOADING_MUSIC = 'UPLOADING_MUSIC'
export const UPLOADED_MUSIC = 'UPLOADED_MUSIC'
export const FAILED_UPLOAD_MUSIC = 'FAILED_UPLOAD_MUSIC'
export const DELETEING_MUSIC = 'DELETEING_MUSIC'
export const DELETED_MUSIC = 'DELETED_MUSIC'
export const SELECT_MUSIC = 'SELECT_MUSIC'

export const MAP_CHANGE = 'MAP_CHANGE'

export const COVER_CHANG = 'COVER_CHANG'
export const $CROPPER_MODAL = '$CROPPER_MODAL'

export const SAVED_PAGES = 'SAVED_PAGES'

export const ADD_TEXT_ELM = "ADD_TEXT_ELM"

export const contentChange = (content, path, target) => ({
    type: CONTENT_CHANGE,
    content,
    path,
    target
})

export const cssChange = (path, css) => ({type: CSS_CHANGE, path, css})

export const fetching = () => ({type: FETCHING})

export const fetched = pages => ({type: FETCHED, pages})

export const fetchError = error => ({type: FETCH_ERROR, error})

export const switchTo = index => ({type: SWITCH_TO, index})

export const reOrder = (ordered, target, pages) => ({type: RE_ORDER, ordered, target, pages})

export const selectElm = (path, ctrl, force) => ({type: SELELCT_ELM, path, ctrl, force})

export const fileQueued = file => ({type: FILE_QUEUED, file})

export const fileProgress = (id, percentage) => ({type: FILE_PROGRESS, id, percentage})

export const fileStatusChange = (id, status, response) => ({type: FILE_STATUS_CHANGE, id, status, response})

export const markEditable = path => ({type: MARK_EDITABLE, path})
export const unMarkEditable = path => ({type: UNMARK_EDITABLE, path})

export const deleteElm = path => ({type: DELETE_ELM, path})


export const selectPhoto = (id) => ({type: SELECT_PHOTO, id})
export const switchPage = page => ({type: SWITCH_PAGE, page})

export const selectedPhoto = (photo) => ({type: SELECTED_PHOTO, photo})
export const deletedPhote = (id) => ({type: DELETED_PHOTO, id})
export const cropperReady = (isReady) => ({type: CROP_READY, isReady})

export const searching = () => ({type: SEARCHING})
export const keywordChange = (key) => ({type: 'KEYWORD_CHANGE', key})
export const searched = list => ({type: SEARCHED, list})
export const playMusic = src => ({type: PLAY_MUSIC, src})
export const puaseMusic = () => ({type: PUASE_MUSIC})
export const loadedMusicSrc = song => ({type: LOADED_MUSIC_SRC, song})
export const switchSearchPage = page => ({type: SWITCH_SEARCH_PAGE, page})
export const uploadingMusic = file => ({type: UPLOADING_MUSIC, file})
export const uploadedMusic = (id, res) => ({type: UPLOADED_MUSIC, id, res})
export const failedUploadMusic = id => ({type: FAILED_UPLOAD_MUSIC, id})
export const deleteingMusic = id => ({type: DELETEING_MUSIC, id})
export const deletedMusic = id => ({type: DELETED_MUSIC, id})
export const selectMusic = song => ({type:SELECT_MUSIC, song})

export const mapChange = map => ({type: MAP_CHANGE, map})

export const coverChange = cover => ({type: COVER_CHANG, cover})
export const $cropperModal = $cropper => ({type:$CROPPER_MODAL, $cropper})

export const savedPages = pages => ({type:SAVED_PAGES, pages})

export const focusElm = path => ({type: FOCUS_ELM, path})

export const draging = ev => ({type: DRAGING, x: ev.screenX , y: ev.screenY})
export const draged = () => ({type: DRAGED})

export const editing = ev => ({type: EDITING})
export const edited = () => ({type: EDITED})

export const resized = ev => ({type: RESIZED})
export const resizing = (ev, dot) => ({type: RESIZING, ev, dot})

export const styleChange = (path, style) => ({type: STYLE_CHANGE, style, path})

export const undo = () => ({type: UNDO})
export const redo = () => ({type: REDO})

export const addTextElm = () => ({type: ADD_TEXT_ELM})